from .base import Handler
from event_engine.event import Event
from event_engine.engine import EventEngine
from models.task_queue import TaskQueue
from models.task import Task


class SaveTaskHandler(Handler):
    """
    保存任务
    """

    def process(self, event: Event, engine: EventEngine) -> None:
        # 向任务队列添加任务
        TaskQueue.put(Task(
            type=event.data["type"],
            url=event.data["url"],
            referer=event.data["referer"],
        ))
